package com.yitiao.data_algorithms.leetcode.editor.cn;
import com.yitiao.data_algorithms.leetcode.editor.cn.base.ListNode;
import com.yitiao.data_algorithms.leetcode.editor.cn.base.TreeNode;

import java.util.Stack;

class ReverseBits{
    // 2022-09-07 15:15:16
    public static void main(String[] args) {
        Solution solution = new ReverseBits().new Solution();
    }
    
    //leetcode submit region begin(Prohibit modification and deletion)
public class Solution {
    // you need treat n as an unsigned value
    public int reverseBits(int n) {
        Stack<Integer> stack = new Stack<>();
        int ans = 0;
        for (int i = 0; i < 32; i++) {
           ans = ((ans<<1)+(n&1));
//            ans = (ans+(n&1))<<1;
           n>>=1;
        }
        return ans;
    }
}
//leetcode submit region end(Prohibit modification and deletion)

}